package com.fcfactory.eggutils.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @autuor 范大晨
 * @Date 2023/9/19 19:01
 * @description 统一结果返回类
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class RestResponse {
    //状态码 1成功 -1失败
    private String code;
    //数据
    private Object data;
    //信息
    private String message;

    public static  RestResponse success(Object data){
        return new RestResponse("1",data,"操作成功");
    }

    public static RestResponse success(){
        return new RestResponse("1","","操作成功");
    }

    public static RestResponse err(){
        return new RestResponse("-1","","操作失败");
    }

    public static RestResponse err(Exception e){
        return new RestResponse("-1",e.getMessage(),"操作失败");
    }
}
